<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>ACC670101A</title>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function() {
				$("#search").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        });
				$("#add").button({
		            icons: {
		                primary: "ui-icon-plusthick"
		            }
		        }).click(function() {
		        	document.getElementById("job").value = "add";
		        	$("#searchForm").submit();
		        });
		        $(".update-link").button({
		            icons: {
		                primary: "ui-icon-pencil"
		            },
            		text: false
		        });
		        $(".delete-link").button({
		            icons: {
		                primary: "ui-icon-closethick"
		            },
            		text: false
		        });
			});

			function delUser(userId){
				if(confirm('คุณต้องการลบผู้ใช้งานใช่หรือไม่?')==true){
					window.location='${pageContext.request.contextPath}/acc67?app=ACC670101&job=delete&userId='+userId;
				}
			}
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC670101')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc67" method="post">
		<input type="hidden" name="app" id="app" value="ACC670101"/>
		<input type="hidden" name="job" id="job" value="search"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC670101}</b></th>
			</tr>
			<tr>
				<td colspan="2" align="right"><button id="add" type="button" class="acc67-button">เพิ่มข้อมูล</button></td>
			</tr>
			<tr>
				<td width="20%" class="bold">รหัสผู้ใช้งานระบบ : </td>
				<td><input type="text" id="userId" name="userId" size="15" maxlength="15" value="${user.userId}"/></td>
			</tr>
			<tr>
				<td width="20%" class="bold">ชื่อผู้ใช้งานระบบ : </td>
				<td><input type="text" id="userName" name="userName" size="30" maxlength="50" value="${user.userName}"/></td>
			</tr>
			<tr>
				<td width="20%" class="bold">เลขประจำตัวประชาชน : </td>
				<td><input type="text" id="citizenId" name="citizenId" size="15" maxlength="13" onkeypress="return numberOnly(event);" value="${user.citizenId}"/></td>
			</tr>
			<tr>
				<td width="20%" class="bold">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel =='3'}">
						<c:forEach var="data" items="${userInfo.listUserProvice}">
							${data.provinceName}
							<input type="hidden" name="areaCode" id="areaCode" value="${data.provinceId}">
						</c:forEach>
					</c:if>
					<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
						<select name="areaCode" id="areaCode">
							<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								<c:if test="${data.provinceId == user.areaCode}" var="provinceSeleted"/>
								<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
							</c:forEach>
						</select>
					</c:if>
				</td>
			</tr>
			<tr>
				<td class="bold">สิทธิ์ผู้ใช้งานระบบ : </td>
				<td>
					<select name="roleId" id="roleId">
						<option value="">----- เลือก -----</option>
						<c:forEach var="role" items="${lsRole}">
						<c:if var="selected" test="${user.roleId == role.ROLE_ID}" />
							<option value="${role.ROLE_ID}" ${selected ? 'selected' : ''}>${role.ROLE_NAME}</option>
					    </c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><button id="search" type="submit" class="acc67-button">ค้นหาข้อมูล</button></td>
			</tr>
			<c:if test="${!empty pageBean.pageData}">
			<tr>
				<td colspan="2">
					<fieldset>
						<legend>แสดงรายการ</legend>
						<br/>
						<table class="acc67-grid ui-widget ui-widget-content" width="100%" cellpadding="1" cellspacing="1">
							<tr>
								<th class="ui-state-default" width="15%" onclick="pageControl('S', 'USER_ID');"><span id="USER_ID" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>รหัสผู้ใช้งานระบบ</th>
								<th class="ui-state-default" onclick="pageControl('S', 'USER_NAME');"><span id="USER_NAME" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>ชื่อผู้ใช้งานระบบ</th>
								<th class="ui-state-default" onclick="pageControl('S', 'CITIZEN_ID');"><span id="CITIZEN_ID" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>เลขประจำตัวประชาชน</th>
								<th class="ui-state-default" onclick="pageControl('S', 'AREA_CODE');"><span id="AREA_CODE" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>จังหวัด</th>
								<th class="ui-state-default" onclick="pageControl('S', 'ROLE_ID');"><span id="ROLE_ID" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>สิทธิ์ผู้ใช้งานระบบ</th>
								<th class="ui-state-default" width="10%">สถานะ</th>
								<c:if test="${fn:contains(auth, 'U')}">
									<th class="ui-state-default" width="5%">แก้ไข</th>
								</c:if>
								<!-- <th class="ui-state-default" width="3%">ลบ</th> -->
							</tr>
							<c:forEach var="data" items="${pageBean.pageData}" varStatus="x">
							<tr class="grid-tr-${x.count % 2}">
								<td align="center">${data.userId}</td>
								<td>&nbsp;${data.userName}</td>
								<td align="center">&nbsp;${data.citizenId}</td>
								<td align="center">&nbsp;${el:getDataUtil('PAN', data.areaCode)}</td>
								<td align="center">&nbsp;${el:getDataUtil('ROL', data.roleId)}</td>
								<td align="center">&nbsp;${el:getUserStatus(data.active)}</td>
								<c:if test="${fn:contains(auth, 'U')}">
									<td align="center"><a href="${pageContext.request.contextPath}/acc67?app=ACC670101&job=view&userId=${data.userId}" class="acc67-button update-link">แก้ไข</a></td>
								</c:if>
								<%-- <td align="center"><a href="##" onclick="delUser('${data.userId}');" class="acc67-button delete-link">ลบ</a></td> --%>
							</tr>
							</c:forEach>
						</table>
						<input type="hidden" name="formPage" id="formPage" value="searchForm"/>
						<c:import url="/apps/page.jsp"/>
					</fieldset>
				</td>
			</tr>
			</c:if>
		</table>
		</form>
	</body>
</html>